package elicecn.web.struts2ext.dto;

import java.io.Serializable;

@SuppressWarnings("serial")
public abstract class BaseDto implements Serializable {
	public static String DIR_DESC = "DESC";
	public static String DIR_ASC = "ASC";

	private int start;

	private int limit = 50;

	private String sort;

	private String dir;

	private boolean needCount;

	private int totalCount;

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public void calcStart() {
		if (start >= totalCount) {
			start = ((int) ((totalCount - 1) / limit)) * limit;
		}
	}

	public void setPgNumber(int pgNumber) {
		if (pgNumber < 1)
			pgNumber = 1;

		start = (pgNumber - 1) * limit;
	}

	public int getPgNumber() {
		return start / limit + 1;
	}

	public int getEnd() {
		return this.start + this.limit;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public boolean isNeedCount() {
		return needCount;
	}

	public void setNeedCount(boolean needCount) {
		this.needCount = needCount;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getDir() {
		return dir;
	}

	public void setDir(String dir) {
		this.dir = dir;
	}

}